package com.jzo2o.foundations.controller.consumer;


import com.jzo2o.foundations.model.domain.ServeSearch;
import com.jzo2o.foundations.model.dto.response.HotServeListResDTO;
import com.jzo2o.foundations.model.dto.response.ServeAggregationSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeAggregationTypeSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeCategoryResDTO;
import com.jzo2o.foundations.service.IRegionServeService;
import com.jzo2o.foundations.service.IServeSearchEsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * \* User: chy
 * \* Date: 2025/9/27  10:16
 * \* Description:
 * \
 */
@RestController
@RequestMapping("/customer/serve")
@Api(tags = "小程序端 - 服务列表展示相关接口")
@Slf4j
public class CustomerServeController {

    @Resource
    private IRegionServeService regionServeService;
    @Resource
    private IServeSearchEsService serveSearchEsService;

    /**
     * 小程序端首页服务列表
     *
     * @param regionId 区域id
     * @return 首页服务列表
     */
    @GetMapping("/firstPageServeList")
    @ApiOperation("获取首页服务列表")
    public List<ServeCategoryResDTO> getFirstPageServeList(Long regionId ) {
        log.info("获取首页服务列表区域id:{}", regionId);
        return regionServeService.queryCategoryList(regionId);
    }
    /**
     * 小程序端首页热门服务列表
     *
     * @param regionId 区域id
     * @return 首页服务列表
     */
    @GetMapping("/hotServeList")
    @ApiOperation("获取热门服务列表")
    public List<HotServeListResDTO> getHotServeList(Long regionId ) {
        log.info("获取热门服务列表区域id:{}", regionId);
        return regionServeService.queryHotServeList(regionId);
    }
    /**
     * 小程序端服务类型列表
     *
     * @param regionId 区域id
     * @return 服务类型列表
     */
    @GetMapping("/serveTypeList")
    @ApiOperation("获取服务类型列表")
    public List<ServeAggregationTypeSimpleResDTO> getServeTypeList(Long regionId ) {
        log.info("获取服务类型列表区域id:{}", regionId);
        return regionServeService.getAllTypeByRegionId(regionId);
    }
    /**
     * 小程序端服务详情
     *
     * @param id 服务id
     * @return 服务详情
     */
    @GetMapping("/{id}")
    @ApiOperation("获取服务详情")
    public ServeAggregationSimpleResDTO getServeDetail(@PathVariable Long id) {
        log.info("获取服务详情id:{}", id);
        return regionServeService.queryServeDetail(id);
    }
    /**
     * 小程序端所用es进行搜索的功能
     *
     * @param cityCode 城市编码
     * @param serveTypeId 服务类型id
     * @return 服务列表
     */
    @GetMapping("/search")
    @ApiOperation("小程序端根据服务类型查询服务列表")
    public List<ServeSearch> queryServeListByType(String cityCode, String keyword , Long serveTypeId){
        log.info("小程序端根据服务类型查询服务列表,cityCode:{}", cityCode);
        return serveSearchEsService.querySaleServeSearchList(cityCode, keyword, serveTypeId);
    }
}
